<?php
namespace tp5_lib\account\model;

use think\Model;

/**
 * 充值记录
 * @property string $id
 * @property string $user_id 要修改的用户ID
 * @property string $amount 金额
 * @property string $way 方式
 * @property string $account 账号(支付宝账号、微信账号、银行卡ID)
 * @property string $status 状态
 * @property string $time
 */
class WithdrawModel extends Model
{
    protected $table="account_withdraw";
    public function __construct($data=[])
    {
        parent::__construct($data);
        if(isset($this["time"])){
            $this["time_str"]=date("Y-m-d H:i:s",$this["time"]);
        }
        
        $status_enum=[
            0=>"等待处理",
            1=>"提现成功",
            2=>"提现失败",
        ];
        if(isset($this["status"])){
            $this["status_str"]=$status_enum[$this["status"]];
        }
    }
    public function install()
    {
        $table=$this->db()->getTable();
        $sql="CREATE TABLE IF NOT EXISTS `$table` ( 
            `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 
            `user_id` INT NOT NULL , 
            `amount` decimal(10,2) NOT NULL,
            `way` varchar(20) NOT NULL,
            `account` varchar(40) NOT NULL,
            `status` int(11) NOT NULL,
            `time` int(11) NOT NULL
        ) ENGINE = InnoDB;";
        $this->db()->execute($sql);
    }
}
